<?php
class Control_ActivityConf_downLoad {
	function downLoad() {
		$node_id = MooForm::request('node_id');
		$type = MooForm::request('type');
		$nodeObj = MooDao::get('Node')->load($node_id);
		
		if(!$nodeObj) {
			exit("该文件不存在");
		}
		
		!$type && $type = "excel";
		if($type == "excel") {
			$filePath = $nodeObj->node_path;
			$fileName = $nodeObj->excel_name;
		} else if ($type == "xml") {
			$filePath = $nodeObj->xml_path;
			$fileNames = explode("/", $filePath);
			$num = count($fileNames) - 1;
			$fileName = $fileNames[$num];
		} else if($type == "lua") {
			$filePath = $nodeObj->lua_path;
			$node_game= $nodeObj->node_game;
			$node_activity_id = $nodeObj->node_activity_id;
			
			$activityInfo = MooObj::get('ActivityConf')->getActivityInfoByEn($node_game, $node_activity_id);
			$activityId = $activityInfo['activityId'];
			
			if(strtoupper(substr(PHP_OS,0,3))==='WIN') {
				$fileNames = explode("\\", $filePath);
			} else {
				$fileNames = explode("/", $filePath);
			}			
			
			$num = count($fileNames) - 1;
			$fileName = $fileNames[$num];
			
			$excelName = $nodeObj->excel_name;
			$luaId = $activityInfo['xmlLua'][$excelName]['luaId'] ? $activityInfo['xmlLua'][$excelName]['luaId'] : 1;
			
			$fileName = "Activity_{$activityId}_{$luaId}.lua";
		}
		
		MooUtil::downFile($filePath, $fileName);
	}
}